package com.letoken.platform.repo.app.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.letoken.platform.pub.util.LocalDateTool;
import com.letoken.platform.repo.admin.req.user.AdminBalanceHistoryListReq;
import com.letoken.platform.repo.admin.res.user.AdminBalanceHistoryRes;
import com.letoken.platform.repo.app.req.user.BalanceHistoryReq;
import com.letoken.platform.repo.app.req.user.LpLockHistoryReq;
import com.letoken.platform.repo.app.res.user.AppBalanceHistoryRes;
import com.letoken.platform.repo.app.res.user.AppLpAssetHistoryRes;
import com.letoken.platform.repo.app.res.user.AppLpLockHistoryRes;
import com.letoken.platform.repo.mall.po.AppBalanceHistory;
import com.letoken.platform.repo.mall.po.AppLpLockHistory;
import org.apache.catalina.LifecycleState;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 余币报资产 Mapper 接口
 * </p>
 *
 * @author author
 * @since 2023-07-25
 */
public interface AppLpLockHistoryMapper extends BaseMapper<AppLpLockHistory> {


    @Select("select id, user_id,seq_no,amount from app_lp_lock_history where type = 0 and unlock_time < #{now}")
    List<AppLpLockHistory> selectNeedUnLockHistorys(@Param("now")LocalDateTime now);


    @Select("select id ,amount,type,unlock_time from app_lp_lock_history where user_id = #{req.userId} order by create_time desc ")
    Page<AppLpLockHistoryRes> history(@Param("page") Page<AppLpLockHistoryRes> page , @Param("req") LpLockHistoryReq req);


    @Select("select id ,amount,type,create_time from app_user_assets_history where user_id = #{req.userId} and token_id = 5  and (type = 1 or type = 2) order by create_time desc ")
    Page<AppLpAssetHistoryRes> assetHistory(@Param("page") Page<AppLpAssetHistoryRes> page , @Param("req") LpLockHistoryReq req);

    @Select("select sum(amount) amount,user_id userId from app_lp_lock_history where type =0 and create_time>'2024-06-11 18:00:00' GROUP BY user_id HAVING sum(amount) >=550")
    List<AppLpLockHistory> getLockLp();


}
